/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author LOBA
 */
public class DBconnection {
    private Connection conn = null;
private static DBconnection dBConn = null;
static final String DB_URL = "jdbc:mysql://localhost:3306/db";
static final String DB_USER = "root";
static final String DB_PASS = "";

private DBconnection(){
    if (conn == null) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(DB_URL,DB_USER,DB_PASS);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public static DBconnection getInstance(){
    DBconnection conn = null;
if (dBConn == null) {
dBConn = new DBconnection();
conn = dBConn;
} else {
conn = dBConn;
}
return conn;
}
public Connection getCon() throws SQLException {
return this.conn;
}
}


